package org.teststack.Api;

import com.jayway.restassured.RestAssured;
import com.jayway.restassured.response.Response;

import java.util.HashMap;
import java.util.Map;

import static org.teststack.Api.CookieManager.cookies;

public class SllrkApi {

    public static void main(String[] args) {
        sllrkApi("47e9b525751f4ad8bc743faa9e268af9","1","1","1");
    }

    public static int sllrkApi(String checkCodeId, String currentPage, String currentPage_wdqm, String currentPage_wdhy) {
        // 登录并更新cookies
 //       RestClient.loginAndUpdateCookies("liutao", "xQ5Vea/L3CMRNEwoBESSZGSVCnValY4kZcAYe3153B9/dXpazZRG8VLEuMhJdW1RhdZ/cqdUq/5FUdAxeKzdWOmZEj0sVlobwrqzRMgrIPsvyp03QTktVYRUAgloA924e5wLLSx8ECJ4WpUAB8zUa41GkyURFmyVtwxQ3EkLuabQ7V24L8EdzRfBHnFd8zRRd4RkncACXO88rrb4U7uR10ANvR0K4N2Kiai901pyztSuMfXP0fVRBW1lKj+kIONtFufTZoAL48++Q6VVr3r5B9tIC4kkwv0WzQxeOubbVKTNUi1JGnS2CEPPqjuXWJnUAO3u5PRxXmtH5+JN8yXygw==");


        Map<String, String> formParams = new HashMap<>();
        formParams.put("checkCodeId", checkCodeId);
        formParams.put("currentPage", currentPage);
        formParams.put("currentPage_wdqm", currentPage_wdqm);
        formParams.put("currentPage_wdhy", currentPage_wdhy);


        Response response = RestAssured.given()


                .cookies(cookies)
                .params(formParams)

                .post("http://10.1.10.141:9031/unite.do?method=enterQykb"); // 注意：可能需要有效的 CSRF Token

        int statusCode = Integer.parseInt(String.valueOf(response.getStatusCode()));
        Map<String, String> cookies = response.getCookies();
        System.out.println(statusCode);
        String body = response.getBody().asString();



        return statusCode;
    }


}
